<script>
    jxt.root.newJson = function (dataJson, attrs) {
        var title;
        var pageid;
        if (attrs) {
            title = attrs.title;
            pageid = attrs.pageid;
        }
        if (!dataJson) dataJson = jxt.root.dataJson;
        var _self = jxt.tag.newJson(dataJson);
        _self.id = jxt.root.dataJson.id + pageid;
        _self.children = [];

        if (pageid) _self.pageid = pageid;
        if (!title) title = jxt.root.dataJson.init.title;
        _self.title = title;
        return _self;

    };

    jxt.root.add = function (newnode, at_id) {
        if (at_id && eleExits(at_id)) {
            $("#" + at_id).after('<div id=' + newnode.id + ' ></div>');
        } else {
            $("#" + jxt.eleid).append('<div id=' + newnode.id + ' ></div>');
        }
        if (!eleExits(newnode.id)) {
            alert("root添加node失败！");
        }
        return jxt.tag.add(jxt.data[0], newnode, at_id);

    };

    jxt.root._addnode = function (source_id, eventkey, attrs) {
        var newn = attrs.newnodelist;
        var n;
        if ($.type(newn) == "array") {
            n = newn[0];
        } else {
            n = newn;
        }
        jxt.root.add(n, jxt.nowlevoneid);
        jxt.msg.radio("root", "nodechange");
    };

    jxt.msg.subscribe("root", "addmainnode", jxt.root._addnode);
</script>